#ifndef FORMCLIENT_H
#define FORMCLIENT_H

#include <QWidget>
#include <QStandardItemModel>
#include <QDebug>
#include "listeclient.h"
#include <QStringList>
#include <QStringListModel>
#include <QDesktopServices>
#include "databasemanager.h"
#include "laddatabasemanager.h"

namespace Ui {
class FormClient;
}

class FormClient : public QWidget
{
    Q_OBJECT
    
public:
    explicit FormClient(databaseManager &datab, ListeClient &listeClient, QStringList &listeTypeClient, ListeTypePrestation &listeTypePrestation, bool newMode = false, QWidget *parent = 0);
    ~FormClient();
public slots:
    void ReceptionClient(Client *client);

private slots:
    void AjouterClient();
    void AjouterContact();
    void AjouterDateContact();
    void AjoutTypePrestation();
    void AjouterDateObtenu();

    void ModifierClient();
    void ModifierContact();
    void ModifierDateContact(DateContact dateContact);

    void AfficherContact(int index);
    void SelectDateContact(QModelIndex index);
    void SelectDateObtenu(QModelIndex index);

    void DateContactValide();
    void DateContactModifierDate();
    void DateContactEditerCommentaire();
    void DateContactEnvoiMail();

    void UnlockClient(bool u);

    void HideFormClient();
    void NouveauContact();

signals:

    void EnvoiTypeClient(Client client);
    void UpdateAffichage();

private:
    Ui::FormClient *ui;
    QStandardItemModel *m_modelListeDateContact;
    QStandardItemModel *m_modelListeDateObtenu;
    Client *m_client;
    QStringList m_listeDateContactTypePrestation;

    databaseManager *db;
    ladDatabaseManager ladDb;

    ListeClient *m_listeClient;
    QStringList *m_listeTypeClient;
    ListeTypePrestation *m_listeTypePrestation;

    QStringListModel *m_listeTypeClientModel;
    QStringListModel *m_listeTypePrestationModel;
    QStringListModel *m_listeDateContactTypePrestationModel;

    QStandardItemModel *m_listeDateContactModel;
    QStandardItemModel *m_listeDateObtenuModel;

    QAction *actionModifierDateContact;
    QAction *actionValiderDateContact;
    QAction *actionEditerCommentaireDateContact;
    QAction *actionEnvoiMail;

    void CreationGUI();
    void ModeNouveau(bool mode);
    void Affichage();
    void AffichageClient();
    void AfficherListeDateContact();
    void AfficherListeDateObtenu();

    Client *CreationClient();
    Contact CreationContact(int clientId = 0);
    DateContact CreationDateContact(int clientId = 0);
    DateObtenu CreationDateObtenu(int clientId = 0);

};

#endif // FORMCLIENT_H
